home *** CD-ROM | disk | FTP | other *** search
/ Aminet 24 / Aminet 24 (1998)(GTI - Schatztruhe)[!][Apr 1998].iso / Aminet / text / edit / GED_Hexedit.lha / GED_Hexedit / hex / english / searchascii.ged < prev    next >
Text File  |  1998-01-02  |  5KB  |  2 lines

  1. /* Optimized with RexxOpt 1.8 */
  2. OPTIONS RESULTS;if (LEFT(ADDRESS(),6) ~="GOLDED") then;address 'GOLDED.1';'LOCK CURRENT RELEASE=4';if (RC ~=0) then;exit;OPTIONS FAILAT 6;SIGNAL ON SYNTAX;'QUERY Var=Wild Name=Wildcards';'QUERY Var=Suchstring Name=Find';'Query Var=Ersetzenstring Name=Rplc';parse arg start;if start="1"|start="e" then;do;if length(Suchstring)>16 then Suchstring=left(Suchstring,16);'REQUEST Body="Enter search string in ASCII-format (max 16 chars):" Title="Input" Button="!OK|Cancel" Var=Suchstring Max=16 String Old=' Suchstring;if RC>0 then;do;'UNLOCK';exit;end;end;if length(Suchstring)=0 then;do;'UNLOCK';exit;end;if Wild=TRUE&Left(Suchstring,1)=="?" then;do;'REQUEST Problem="The first char of the search string may be no wildcard"';'UNLOCK';exit;end;'QUERY Var=Startzeile Name=Line';'QUERY Var=Startspalte Name=Column';Z1=Startzeile;S1=Startspalte;Zeichenanz=length(Suchstring);Actzeichen=left(Suchstring,1);'QUERY Var=Anzzeilen Name=Lines';'QUERY Var=grkl Name=UseCase';do forever;'FIND Next Quiet String='Actzeichen;'SET Name=Find Value='Suchstring;'QUERY Var=Z2 Name=Line';'QUERY Var=S2 Name=Column';if Z1=Z2&S1=S2 then;do;'GOTO Line='Startzeile;'GOTO Column='Startspalte;'REQUEST Body="Search string not found" Title="Result" Button="!OK"';'UNLOCK';exit;end;if S2>47&S2<64 then;do;if Zeichenanz=1 then;do;if start="e" then call ersetzen;'UNLOCK';exit;end;'QUERY Var=Inhalt Name=Buffer';if (S2+Zeichenanz-1)<64 then;do;Teil=substr(Inhalt,S2,Zeichenanz);if grkl=false then;do;if Wild=TRUE&index(Suchstring,"?")>0 then;do;Teil=suchewild(Teil,Suchstring);end;if upper(Teil)=upper(Suchstring) then;do;if start="e" then call ersetzen;'UNLOCK';exit;end;end;else;do;if Wild=TRUE&index(Suchstring,"?")>0 then;do;Teil=suchewild(Teil,Suchstring);end;if Teil=Suchstring then;do;if start="e" then call ersetzen;'UNLOCK';exit;end;end;end;else;do;Teil=substr(Inhalt,S2,64-S2);Rest=Zeichenanz-64+S2;if Z2<Anzzeilen then;do;'DOWN';'QUERY Var=Inhalt Name=Buffer';'UP';'GOTO Column='S2;if length(Inhalt)>Rest+47 then;do;Teil=Teil||substr(Inhalt,48,Rest);if grkl=false then;do;if Wild=TRUE&index(Suchstring,"?")>0 then;do;Teil=suchewild(Teil,Suchstring);end;if upper(Teil)=upper(Suchstring) then;do;if start="e" then call ersetzen;'UNLOCK';exit;end;end;else;do;if Wild=TRUE&index(Suchstring,"?")>0 then;do;Teil=suchewild(Teil,Suchstring);end;if Teil=Suchstring then;do;if start="e" then call ersetzen;'UNLOCK';exit;end;end;end;end;end;end;if S2<46 then;do;'GOTO Column=47';S2=47;end;Z1=Z2;S1=S2;end;if start="e" then call ersetzen;'UNLOCK';exit;suchewild:procedure;PARSE ARG w,such;do i=1 to length(such);if substr(such,i,1)=="?" then w=overlay("?",w,i,1);end;return w;ersetzen:;'SET Name=Insert Value=False';do until length(Ersetzenstring)=length(Suchstring);'REQUEST Body="Enter replace string in ASCII-format ('||length(Suchstring)||' chars):" Title="Input" Button="!OK|Cancel" Var=Ersetzenstring Max='||length(Suchstring)||' String Old=' Ersetzenstring;if RC>0 then;do;'UNLOCK';exit;end;if length(Ersetzenstring) ~=length(Suchstring) then 'REQUEST Problem="The replace string must have same length as the search string"';end;'SET Name=Rplc Value='||Ersetzenstring;'QUERY Name=Column Var=Spalte';'QUERY Name=Buffer Var=Inhalt';Zeile1=compress(substr(Inhalt,11,35));Zeile2=substr(Inhalt,48);Ersetzenstring2="";if length(Ersetzenstring)>64-Spalte then;do;Ersetzenstring2=right(Ersetzenstring,length(Ersetzenstring)+Spalte-64);Ersetzenstring=left(Ersetzenstring,length(Ersetzenstring)-length(Ersetzenstring2));end;'GOTO Column=1';Zeile1=overlay(c2x(Ersetzenstring),Zeile1,(Spalte-48)*2+1);Zeile2=overlay(Ersetzenstring,Zeile2,Spalte-47);Inhalt=overlay(substr(Zeile1,1,8),Inhalt,11);Inhalt=overlay(substr(Zeile1,9,8),Inhalt,20);Inhalt=overlay(substr(Zeile1,17,8),Inhalt,29);Inhalt=overlay(substr(Zeile1,25,8),Inhalt,38);Inhalt=overlay(substr(Zeile2,1,16),Inhalt,48);'FIX Var=Inhalt';'TEXT stay T="'||Inhalt||'"';if length(Ersetzenstring2)>0 then;do;'DOWN';'QUERY Name=Buffer Var=Inhalt';Zeile1=compress(substr(Inhalt,11,35));Zeile2=substr(Inhalt,48);Zeile1=overlay(c2x(Ersetzenstring2),Zeile1,1);Zeile2=overlay(Ersetzenstring2,Zeile2,1);Inhalt=overlay(substr(Zeile1,1,8),Inhalt,11);Inhalt=overlay(substr(Zeile1,9,8),Inhalt,20);Inhalt=overlay(substr(Zeile1,17,8),Inhalt,29);Inhalt=overlay(substr(Zeile1,25,8),Inhalt,38);Inhalt=overlay(substr(Zeile2,1,16),Inhalt,48);'FIX Var=Inhalt';'TEXT stay T="'||Inhalt||'"';'UP';end;'GOTO Column='||Spalte;return;SYNTAX:;SAY "Sorry, error line" SIGL ":" ERRORTEXT(RC) ":-(";'UNLOCK';exit